/**
 * [PC 登陆页JS]
 *
 * Created by wdb on 5/15/15.
 */
define([
    "jquery",
    "bootstrap",
    "bootbox",
    "jqBootstrapValidation",
    "IO",
    "md5",
    "cookie"
], function($,bootstrap,bootbox,jqBootstrapValidation,IO) {
    $(function() {
        $("input").jqBootstrapValidation({
            preventSubmit: true,
            submitError: function($form, event, errors) {
            },
            submitSuccess: function($form, event) {
                event.preventDefault();
                var login = {};
                login.user_mobile = $("#login_name").val();
                login.user_password = $("#password").val();
                if(login.user_mobile==""||login.user_password==""){
                    bootbox.alert("用户名或密码不能为空");
                    return;
                }
                login.user_password=$.md5(login.user_password);
                IO.get('/adminLogin',login,function (d) {
                   if(d.code==0){
                       //加载处理
                       $('body').css("overflow","hidden");
                       $("#cover").show();
                       // var storage = window.localStorage;
                       // if(storage) {
                       //     data = JSON.stringify(d);
                       //     storage.setItem("data", data);
                       // }

                       // var expiresDate= new Date();
                       // var dd=expiresDate.toLocaleString();
                       // expiresDate.setTime(expiresDate.getTime()+ (12*60 * 60 * 1000));//12小时过期
                       $.cookie('islogin','1',{ expires: 1, path: '/' });
                       //提交完成
                location.href = '/consultationClassification';
                   }else{
                       bootbox.alert(d.msg);
                       $('body').css("overflow","visible");
                       $("#cover").hide();

                   }

                })


            }
        });

    });
});